const str = 'uuu123abc456xxx';
const reg = /(\d{3})(\w{3})(\d{3})/g

const s = str.replaceAll(reg,(match,p1,p2,p3,offset,str,g)=>{
    console.log(match);
    console.log(p1);
    console.log(p2);
    console.log(p3);
    console.log(offset);
    console.log(str);
    return [p1,p2,p3].join("-")
})
console.log(s)
